﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace Norma43
{
    public class DadesNorma43
    {
        public ObservableCollection<Record> llistaRecords { get; set; }

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
        
        private string _sNumBanc = string.Empty;

        public string sNumBanc
        {
            get
            {
                return this._sNumBanc;
            }

            set
            {
                if (this._sNumBanc != value)
                {
                    this._sNumBanc = value;
                    this.OnPropertyChanged("sNumBanc");
                }
            }
        }

        private string _sNumOfici = string.Empty;

        public string sNumOfici
        {
            get
            {
                return this._sNumOfici;
            }

            set
            {
                if (this._sNumOfici != value)
                {
                    this._sNumOfici = value;
                    this.OnPropertyChanged("sNumOfici");
                }
            }
        }

        private string _sNumCTA = string.Empty;

        public string sNumCTA
        {
            get
            {
                return this._sNumCTA;
            }

            set
            {
                if (this._sNumCTA != value)
                {
                    this._sNumCTA = value;
                    this.OnPropertyChanged("sNumCTA");
                }
            }
        }

        private string _dDataIni = string.Empty;

        public string dDataIni
        {
            get
            {
                return this._dDataIni;
            }

            set
            {
                if (this._dDataIni != value)
                {
                    this._dDataIni = value;
                    this.OnPropertyChanged("dDataIni");
                }
            }
        }

        private string _dDataFi = string.Empty;

        public string dDataFi
        {
            get
            {
                return this._dDataFi;
            }

            set
            {
                if (this._dDataFi != value)
                {
                    this._dDataFi = value;
                    this.OnPropertyChanged("dDataFi");
                }
            }
        }

        private string _sHavDeb = string.Empty;

        public string sHavDeb
        {
            get
            {
                return this._sHavDeb;
            }

            set
            {
                if (this._sHavDeb != value)
                {
                    this._sHavDeb = value;
                    this.OnPropertyChanged("sHavDeb");
                }
            }
        }

        private double _nSaldoIni = 0;

        public double nSaldoIni
        {
            get
            {
                return this._nSaldoIni;
            }

            set
            {
                if (this._nSaldoIni != value)
                {
                    this._nSaldoIni = value;
                    this.OnPropertyChanged("nSaldoIni");
                }
            }
        }

        private string _sDivisa = string.Empty;

        public string sDivisa
        {
            get
            {
                return this._sDivisa;
            }

            set
            {
                if (this._sDivisa != value)
                {
                    this._sDivisa = value;
                    this.OnPropertyChanged("sDivisa");
                }
            }
        }

        private string _sNomCurt = string.Empty;

        public string sNomCurt
        {
            get
            {
                return this._sNomCurt;
            }

            set
            {
                if (this._sNomCurt != value)
                {
                    this._sNomCurt = value;
                    this.OnPropertyChanged("sNomCurt");
                }
            }
        }

    }
    public class Record : IComparable
    {
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }

        private string _sOficina = string.Empty;

        public string sOficina
        {
            get
            {
                return this._sOficina;
            }

            set
            {
                if (this._sOficina != value)
                {
                    this._sOficina = value;
                    this.OnPropertyChanged("sOficina");
                }
            }
        }

        private string _dDataOperacio = string.Empty;

        public string dDataOperacio
        {
            get
            {
                return this._dDataOperacio;
            }

            set
            {
                if (this._dDataOperacio != value)
                {
                    this._dDataOperacio = value;
                    this.OnPropertyChanged("dDataOperacio");
                }
            }
        }

        private string _dDataValor = string.Empty;

        public string dDataValor
        {
            get
            {
                return this._dDataValor;
            }

            set
            {
                if (this._dDataValor != value)
                {
                    this._dDataValor = value;
                    this.OnPropertyChanged("dDataValor");
                }
            }
        }

        private string _sConcepteComu = string.Empty;

        public string sConcepteComu
        {
            get
            {
                return this._sConcepteComu;
            }

            set
            {
                if (this._sConcepteComu != value)
                {
                    this._sConcepteComu = value;
                    this.OnPropertyChanged("sConcepteComu");
                }
            }
        }

        private string _sConceptePropi = string.Empty;

        public string sConceptePropi
        {
            get
            {
                return this._sConceptePropi;
            }

            set
            {
                if (this._sConceptePropi != value)
                {
                    this._sConceptePropi = value;
                    this.OnPropertyChanged("sConceptePropi");
                }
            }
        }

        private int _sDebeHaber = 1;

        public int sDebeHaber
        {
            get
            {
                return this._sDebeHaber;
            }

            set
            {
                if (this._sDebeHaber != value)
                {
                    this._sDebeHaber = value;
                    this.OnPropertyChanged("sDebeHaber");
                }
            }
        }

        private double _fImport = 0;

        public double fImport
        {
            get
            {
                return this._fImport;
            }

            set
            {
                if (this._fImport != value)
                {
                    this._fImport = value;
                    this.OnPropertyChanged("fImport");
                }
            }
        }

        private string _sConcepte1 = string.Empty;

        public string sConcepte1
        {
            get
            {
                return this._sConcepte1;
            }

            set
            {
                if (this._sConcepte1 != value)
                {
                    this._sConcepte1 = value;
                    this.OnPropertyChanged("sConcepte1");
                }
            }
        }

        private string _sconcepte2 = string.Empty;

        public string sconcepte2
        {
            get
            {
                return this._sconcepte2;
            }

            set
            {
                if (this._sconcepte2 != value)
                {
                    this._sconcepte2 = value;
                    this.OnPropertyChanged("sconcepte2");
                }
            }
        }

        public int CompareTo(object obj)
        {
            Record record = obj as Record;
            if (record == null)
                throw new ArgumentException("L'objecte no és un record");

            if (record.dDataOperacio.CompareTo(this.dDataOperacio) == 0)    //Si les punutacions són iguals
                return record.dDataValor.CompareTo(this.dDataValor);    //Comparem les frases resoltes
            else
                return record.dDataOperacio.CompareTo(this.dDataOperacio);  //Si no son iguals comparem puntuaico
        }

    }
}
